package net.sudot.chess.config;

import net.sudot.commons.utils.SnowflakeIdWorker;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 序号生成器
 *
 * @author tangjialin on 2018-06-01.
 */
@Configuration
public class SnConfiguration {

    /**
     * 游戏订单编号
     *
     * @return 返回编号生成器
     */
    @Bean("orderGameServiceSnowflakeIdWorker")
    public SnowflakeIdWorker orderGameServiceSnowflakeIdWorker() {
        return new SnowflakeIdWorker(0, 1);
    }

    /**
     * 充值订单编号
     *
     * @return 返回编号生成器
     */
    @Bean("orderRechargeServiceSnowflakeIdWorker")
    public SnowflakeIdWorker orderRechargeServiceSnowflakeIdWorker() {
        return new SnowflakeIdWorker(0, 0);
    }

    /**
     * 支付事务编号生成器
     *
     * @return 返回编号生成器
     */
    @Bean("paymentTransactionServiceSnowflakeIdWorker")
    public SnowflakeIdWorker paymentTransactionServiceSnowflakeIdWorker() {
        return new SnowflakeIdWorker(0, 2);
    }
}